import router from './Router'
const withList = router.getWithRoutes();
//根据需求重写路由守卫
router.beforeEach((to, from, next) => {
	if (withList.includes(to.path)) {
		if(uni.getStorageSync('userInfo')){
			uni.navigateTo({
				url: 'uni_modules/sxran-im-modules/pages/index/index'
			})
		}else{
			next();
		}
	} else {
		if (!uni.getStorageSync('userInfo')) {
			next(false);
			uni.navigateTo({
				url: 'uni_modules/sxran-im-modules/pages/login/login'
			})
		} else {
			if(!uni.$Im.isSocketConnected()){
				uni.$Im.connect();
			}
		}
	}
});

export default router;